/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:38:03 AM
 * To change this template use File | Settings | File Templates.
 */
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            InternalSchemaErrorException, RuleDefinition, RegexpDefinition, BoolexpDefinition,
//            Schema

abstract class Definition
{

    Definition(Element element)
    {
        id = element.getAttributeValue("id");
        if(id == null)
        {
            throw new InternalSchemaErrorException();
        } else
        {
            id = Schema.replacePrefix(id, element);
            return;
        }
    }

    static Definition parse(Element element, Schema schema)
    {
        String s = element.getName();
        Object obj;
        if(s.equals("rule"))
            obj = new RuleDefinition(element, schema);
        else
        if(s.equals("stringtype") || s.equals("contenttype"))
            obj = new RegexpDefinition(element, schema, s.equals("contenttype"));
        else
        if(s.equals("boolexp"))
            obj = new BoolexpDefinition(element, schema);
        else
            throw new InternalSchemaErrorException();
        return ((Definition) (obj));
    }

    String id;
}
